const { regeneratorRuntime, md5 } = global

Page(global.connect(
  state => ({
    ...state.globalReducer
  }),
  dispatch => ({
    handleRoute: global.handleRoute,
    handleLicon1Tap(e) {
      console.log('handleLicon1Tap', e)
      wx.navigateBack()
    },
    async handleSubmit(e) {
      console.log('handleSubmit', e.detail.value)
      const {
        ori_pwd, new_pwd, conf_pwd
      } = e.detail.value
      const actionRes = await dispatch(global.profileReducer.updatePassword({
        ori_pwd: md5(ori_pwd),
        new_pwd: md5(new_pwd),
        conf_pwd: md5(conf_pwd),
        id: this.data.minaLoginRes.data.user_id
      }))
      console.log(actionRes)
      if (actionRes.actionStatus === 'SUCCESS') {
        this.selectComponent('#toast').handleShow({
          type: 'success',
          message: actionRes.apiMes
        })
        setTimeout(() => {
          wx.navigateBack()
        }, 1000);
      } else {
        this.selectComponent('#toast').handleShow({
          message: actionRes.apiMes
        })
      }
    }
  })
)({
  onLoad(options) {
    console.log('Modpwd onLoad')
  },
}))
